USE [master]
GO
/****** Object:  Database [BookmarksDB]    Script Date: 7/24/2013 21:12:04 ******/
CREATE DATABASE [BookmarksDB]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'BookmarksDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\BookmarksDB.mdf' , SIZE = 4096KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'BookmarksDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\BookmarksDB_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [BookmarksDB] SET COMPATIBILITY_LEVEL = 110
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [BookmarksDB].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [BookmarksDB] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [BookmarksDB] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [BookmarksDB] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [BookmarksDB] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [BookmarksDB] SET ARITHABORT OFF 
GO
ALTER DATABASE [BookmarksDB] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [BookmarksDB] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [BookmarksDB] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [BookmarksDB] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [BookmarksDB] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [BookmarksDB] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [BookmarksDB] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [BookmarksDB] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [BookmarksDB] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [BookmarksDB] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [BookmarksDB] SET  DISABLE_BROKER 
GO
ALTER DATABASE [BookmarksDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [BookmarksDB] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [BookmarksDB] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [BookmarksDB] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [BookmarksDB] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [BookmarksDB] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [BookmarksDB] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [BookmarksDB] SET RECOVERY FULL 
GO
ALTER DATABASE [BookmarksDB] SET  MULTI_USER 
GO
ALTER DATABASE [BookmarksDB] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [BookmarksDB] SET DB_CHAINING OFF 
GO
ALTER DATABASE [BookmarksDB] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [BookmarksDB] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
EXEC sys.sp_db_vardecimal_storage_format N'BookmarksDB', N'ON'
GO
USE [BookmarksDB]
GO
/****** Object:  Table [dbo].[Bookmarks]    Script Date: 7/24/2013 21:12:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Bookmarks](
	[BookmarkID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NOT NULL,
	[Title] [nvarchar](100) NOT NULL,
	[URL] [varchar](100) NOT NULL,
	[Notes] [nvarchar](200) NULL,
 CONSTRAINT [PK_Bookmarks] PRIMARY KEY CLUSTERED 
(
	[BookmarkID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BookmarksTags]    Script Date: 7/24/2013 21:12:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BookmarksTags](
	[BookmarkID] [int] NOT NULL,
	[TagID] [int] NOT NULL,
 CONSTRAINT [PK_BookmarksTags] PRIMARY KEY CLUSTERED 
(
	[BookmarkID] ASC,
	[TagID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Tags]    Script Date: 7/24/2013 21:12:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tags](
	[TagID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Tags] PRIMARY KEY CLUSTERED 
(
	[TagID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UK_Name] UNIQUE NONCLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Users]    Script Date: 7/24/2013 21:12:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Users](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[Username] [varchar](100) NOT NULL,
	[Passwrod] [varchar](100) NULL,
	[Name] [nvarchar](100) NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UK_Username] UNIQUE NONCLUSTERED 
(
	[Username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Bookmarks]  WITH CHECK ADD  CONSTRAINT [FK_Bookmarks_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([UserID])
GO
ALTER TABLE [dbo].[Bookmarks] CHECK CONSTRAINT [FK_Bookmarks_Users]
GO
ALTER TABLE [dbo].[BookmarksTags]  WITH CHECK ADD  CONSTRAINT [FK_BookmarksTags_Bookmarks] FOREIGN KEY([BookmarkID])
REFERENCES [dbo].[Bookmarks] ([BookmarkID])
GO
ALTER TABLE [dbo].[BookmarksTags] CHECK CONSTRAINT [FK_BookmarksTags_Bookmarks]
GO
ALTER TABLE [dbo].[BookmarksTags]  WITH CHECK ADD  CONSTRAINT [FK_BookmarksTags_Tags] FOREIGN KEY([TagID])
REFERENCES [dbo].[Tags] ([TagID])
GO
ALTER TABLE [dbo].[BookmarksTags] CHECK CONSTRAINT [FK_BookmarksTags_Tags]
GO
USE [master]
GO
ALTER DATABASE [BookmarksDB] SET  READ_WRITE 
GO
